/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package core;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class DBAccess {
    public static Connection getConnection(){
        Connection con = null;
        try{
            InputStream str = Thread.currentThread().getContextClassLoader().getResourceAsStream("resource/DBConfig.properties");
            Properties pro = new Properties();
            pro.load(str);
            String name = pro.getProperty("name");
            String pass = pro.getProperty("pass");
            String driver = pro.getProperty("driver");
            String url = pro.getProperty("url");
            Class.forName(driver);
            con = DriverManager.getConnection(url, name, pass);
        }catch(Exception ex){
            Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE, null, ex);
        }
       return con;
    }
}
